package com.qlogic.commons.platform.impls.lucene.model;

import java.io.Serializable;
import java.util.Iterator;
import java.util.LinkedHashMap;

public class DocumentWrapper implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5515528639751544105L;
	
	private String id;
	private String fieldName;
	private String fieldValue;
	private String dependsOn;
	
	private LinkedHashMap fields;
	
	public DocumentWrapper () {
	}
	
	public DocumentWrapper (String id) {
		this.id = id;
	}
	
	public void addField (FieldWrapper field) {
		if (fields == null) {
			fields = new LinkedHashMap ();
		}
		fields.put (field.getName (), field);
	}

	public FieldWrapper getField (String name) {
		if (fields == null) {
			return null;
		}
		return (FieldWrapper)fields.get (name);
	}

	public void removeField (String name) {
		if (fields == null) {
			return;
		}
		fields.remove (name);
	}

	public int getFieldsCount () {
		if (fields == null) {
			return 0;
		}
		return fields.size ();
	}

	public Iterator getFieldNames () {
		if (fields == null) {
			fields = new LinkedHashMap ();
		}
		return fields.keySet ().iterator ();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public LinkedHashMap getFields() {
		return fields;
	}

	public void setFields(LinkedHashMap fields) {
		this.fields = fields;
	}

	public String getDependsOn() {
		return dependsOn;
	}

	public void setDependsOn(String dependsOn) {
		this.dependsOn = dependsOn;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public String getFieldValue() {
		return fieldValue;
	}

	public void setFieldValue(String fieldValue) {
		this.fieldValue = fieldValue;
	}
	
}
